<?php
include("config.php");
include("connection/connection.php");
$pipe_id=$_REQUEST['var'];
$code=$_REQUEST['code'];
$reference_id=$_REQUEST['referenceId'];
$qrSource="select * from tbl_dtls_q1_pipeline_ris_dis where id='$pipe_id'";
		$resSource=mysql_query($qrSource);
		//echo mysql_affected_rows();
		$rowSource=mysql_fetch_array($resSource);
		
		 if(isset($_REQUEST['submit'])){
  
  //print_r($_REQUEST); 
  if($_REQUEST['code']==1) mysql_query("UPDATE tbl_dtls_q1_pipeline_ris_dis set rising_material= '$_REQUEST[material]' , rising_size = '$_REQUEST[size_mm]' , rising_length = '$_REQUEST[length]' WHERE id = '$_REQUEST[pipe_id]' ");
	else mysql_query("UPDATE tbl_dtls_q1_pipeline_ris_dis set distri_material= '$_REQUEST[material]' , distri_size = '$_REQUEST[size_mm]' , distri_length = '$_REQUEST[length]' WHERE id = '$_REQUEST[pipe_id]' ");
  header("Location: q1_rwss_edit.php");
  }
?>
<script type="text/javascript" src="js/jquery.js"></script>
 <div class="section_format">
  <form action="pipelinerwss_edit.php" method="post" name="sec5" id="sec5" onSubmit="return sec6_val();" >
  <input type="hidden" id="pipe_id" name="pipe_id" value="<?php echo $pipe_id; ?>"><input type="hidden" id="code" name="code" value="<?php echo $code; ?>">
  <div style="height:30px" align="center"><?php echo $reference_id;?></div>
  <table border="1">
    <tr>
      <td colspan="2">&nbsp;<b>Pipelines</b>&nbsp;</td>
      </tr>
   
	  
	  <tr>
      <td width="138">&nbsp;<b>Material</b></td>
      <td width="144">&nbsp;
	  <select name="material" id="material" >
	   <option value="0">Select</option>
	   <?php
	  foreach($material as $mat_data){
	  if($mat_data==$rowSource['rising_material'] && $code==1)
	  echo "<option value='".$mat_data."' selected>".$mat_data."</option>";
	  else if($mat_data==$rowSource['distri_material'] && $code==2)
	  echo "<option value='".$mat_data."' selected>".$mat_data."</option>";
	  else
	  echo "<option value='".$mat_data."'>".$mat_data."</option>";
	  }
	   ?>
  	    </select></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Size(mm)</b></td>
      <td>&nbsp;
	  <select name="size_mm" id="size_mm">
	  <option value="0">Select</option>
	  <?php
	  
	  foreach($size as $mm){
	  if($mm==$rowSource['rising_size'] && $code==1)
	  echo "<option value='".$mm."' selected>".$mm."</option>";
	  else if($mm==$rowSource['distri_size'] && $code==2)
	  echo "<option value='".$mm."' selected>".$mm."</option>";
	  else
	echo "<option value='".$mm."'>".$mm."</option>";	  }
	  
	  ?>
	  </select></td>
      </tr>
	  <tr>
	  <td>&nbsp;<b>Length (Km)</b></td>
	 <td>&nbsp;<input type="text" name="length" value="<?php echo $rowSource['rising_length'].$rowSource['distri_length'];  ?>"  onblur="int(this);" /></td>
	  </tr>

	  
	  <tr>
	    <td colspan="2" align="center"><input type="submit" value="EDIT PIPELINE" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:140px; height:30px" onClick="view_validate()"></td>
  </tr>
  </table>
    </form>
  </div>
  
